﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Security.Cryptography;
using WebKpiPage.Data.Common;
using Model;
namespace WebKpiPage.Data.TotalSearch
{
    public static  class TotalSearchDB
    {
      
        public static DataTable GetInfoForInitPage()
        {
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogInfo("AddGongDanRecord  conn == null || conn.State != System.Data.ConnectionState.Open");
                return null;
            }
            try
            {
                string qry_id_list = "2,2,2,2,2,2,2,2,3,4";
                string qry_param_list = "0@1@2@3@5@7@10@11@33@44";
                string commandText = "MTNOH_BASIC_CONF.dbo.PROC_查询_无线综合_界面";
                SqlParameter[] sp = new SqlParameter[2];
                sp[0] = new SqlParameter("@qry_id_list", qry_id_list);
                sp[1] = new SqlParameter("@qry_param_list", qry_param_list);
                SqlDataAdapter ad = SqlHelper.ExecuteDataAdapter(conn, CommandType.StoredProcedure, commandText, sp);
                DataTable dt=new DataTable();
                ad.Fill(dt);
                return dt;
            }
            catch (Exception e)
            {
                LogSystem.LogError("GetInfoForInitPage", e);
                return null;
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }

        /// <summary>
        /// 查询_无线综合
        /// </summary>
        /// <param name="searchPrm"></param>
        /// <returns></returns>
        public static DataTable QueryTotalList(Yu_SearchParams searchPrm)
        {
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogInfo("AddGongDanRecord  conn == null || conn.State != System.Data.ConnectionState.Open");
                return null;
            }
            try
            {
                string commandText = "MTNOH_BASIC_CONF.dbo.PROC_查询_无线综合";
                int count = 8;
                SqlParameter[] sp = new SqlParameter[count];
                sp[--count] = new SqlParameter("@begin_time", searchPrm.begin_time);
                sp[--count] = new SqlParameter("@end_time", searchPrm.end_time);
                sp[--count] = new SqlParameter("@qry_ne_cat", searchPrm.qry_ne_cat);
                sp[--count] = new SqlParameter("@qry_tm_seg", searchPrm.qry_tm_seg);
                sp[--count] = new SqlParameter("@qry_attr_id_list", searchPrm.qry_attr_id_list);
                sp[--count] = new SqlParameter("@filter_ne_cat", searchPrm.filter_ne_cat);
                sp[--count] = new SqlParameter("@filter_obj_list", searchPrm.filter_obj_list);
                sp[--count] = new SqlParameter("@qry_flag", searchPrm.qry_flag);
                SqlDataAdapter ad = SqlHelper.ExecuteDataAdapter(conn, CommandType.StoredProcedure, commandText, sp);
                DataTable dt = new DataTable();
                ad.Fill(dt);
                return dt;
            }
            catch (Exception e)
            {
                LogSystem.LogError("QueryTotalList", e);
                return null;
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
    }
}
